package com.beiye.drivertransport.SubActivity;

import android.content.Context;
import android.content.DialogInterface;
import android.content.SharedPreferences;
import android.graphics.Color;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseExpandableListAdapter;
import android.widget.ExpandableListView;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.alibaba.fastjson.JSON;
import com.beiye.drivertransport.R;
import com.beiye.drivertransport.activity.TwoBaseAty;
import com.beiye.drivertransport.adapter.MyGridViewrecordAdapter;
import com.beiye.drivertransport.bean.CheckBean;
import com.beiye.drivertransport.bean.LearnRecordBean;
import com.beiye.drivertransport.bean.SpecifiedPhotoBean;
import com.beiye.drivertransport.config.AppInterfaceConfig;
import com.beiye.drivertransport.http.Login;
import com.beiye.drivertransport.utils.TiShiDialog;
import com.beiye.drivertransport.utils.Utils;
import com.beiye.drivertransport.view.ShowGridView;
import com.githang.statusbar.StatusBarCompat;
import com.lzy.okgo.OkGo;
import com.lzy.okgo.callback.StringCallback;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


import butterknife.OnClick;
import okhttp3.Call;
import okhttp3.Response;
//未完成学习记录
public class UnfinishLearnRecordActivity extends TwoBaseAty {


    ImageView img_recordback;

    ExpandableListView record_lv;

    View empty_view;

    private MyExpandableListViewAdapter adapter;
    ArrayList<SpecifiedPhotoBean.RowsBean> photoList = new ArrayList<>();

    @Override
    public int getLayoutId() {
        return R.layout.activity_unfinish_learn_record;
    }

    public void onClick(View view) {
        if (view.getId() == R.id.img_recordback) {//返回首页
            SharedPreferences sp = getSharedPreferences("userIdandorgid",
                    Context.MODE_PRIVATE);
            SharedPreferences.Editor edit = sp.edit();
            edit.clear();
            edit.commit();
            finish();
        }

    }

    @Override
    public void onBackPressed() {
        SharedPreferences sp = getSharedPreferences("userIdandorgid",
                Context.MODE_PRIVATE);
        SharedPreferences.Editor edit = sp.edit();
        edit.clear();
        edit.commit();
        super.onBackPressed();
    }

    @Override
    public void initData() {
        img_recordback = (ImageView) findViewById(R.id.img_recordback);
        record_lv = (ExpandableListView) findViewById(R.id.record_expandablelistview);
        empty_view = (View) findViewById(R.id.empty_view);
        StatusBarCompat.setStatusBarColor(this, Color.parseColor("#1F80C4"));
        initUi();
    }
    private void initUi() {
        record_lv.setGroupIndicator(null);//去掉箭头
        record_lv.setEmptyView(empty_view);
        record_lv.setOnChildClickListener(new ExpandableListView.OnChildClickListener() {
            @Override
            public boolean onChildClick(ExpandableListView expandableListView, View view, int groupPosition, int childPosition, long l) {

                return true;
            }
        });
    }
    @Override
    public void requestData() {

        Bundle bundle = getIntent().getExtras();
        String   orgId = bundle.getString("orgId");
        String  userId = bundle.getString("userId");
        int minPer = bundle.getInt("minPer");
        SharedPreferences sp = getSharedPreferences("userIdandorgid",
                Context.MODE_PRIVATE);
        SharedPreferences.Editor edit = sp.edit();
        edit.putInt("minPer",minPer);
        edit.putString("orgId",orgId);
        edit.putString("userId",userId);
        edit.commit();
        //  dialog = CustomProgressDialog.show(SubLearnRecordActivity.this, "", true, null);
        showLoadingDialog("正在加载");
        new Login().getrRecordLearning(userId, orgId,this,1);
    }

    @Override
    protected void onResume() {
        super.onResume();
//        SharedPreferences sp = getSharedPreferences("userIdandorgid",
//                Context.MODE_PRIVATE);
//        String orgId = sp.getString("orgId", "");
//        String userId = sp.getString("userId", "");
//        showLoadingDialog("正在加载");
//        new Login().getrRecordLearning(userId,orgId,this,1);

    }
    @Override
    public void onSuccess(String result, Call call, Response response, int what) {
        if(what==1)
        {
            // dialog.dismiss();
            dismissLoadingDialog();
            Map<LearnRecordBean.RowsBean, List<LearnRecordBean.RowsBean.ListCourseBean>> dataset = new HashMap<>();
            LearnRecordBean learnRecordBean = JSON.parseObject(result, LearnRecordBean.class);
            List<LearnRecordBean.RowsBean> rows = learnRecordBean.getRows();
            for (int i= 0;i< rows.size();i++) {
                List<LearnRecordBean.RowsBean.ListCourseBean> listCourse = rows.get(i).getListCourse();
                dataset.put(rows.get(i),listCourse);
            }
            adapter = new MyExpandableListViewAdapter(UnfinishLearnRecordActivity.this,rows,dataset);
            record_lv.setAdapter(adapter);


        }
        super.onSuccess(result, call, response, what);
    }
        @Override
    public void onError(String result, Call call, Response response, int what) {
        super.onError(result, call, response, what);
        if(what==1)
        {
            dismissLoadingDialog();
            CheckBean checkBean = JSON.parseObject(result, CheckBean.class);
            String msg = checkBean.getMsg();
            dismissLoadingDialog();
            TiShiDialog.Builder builder1 = new TiShiDialog.Builder(UnfinishLearnRecordActivity.this);
            builder1.setMessage(msg);
            builder1.setTitle("提示:");
            builder1.setPositiveButton("我知道", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                    ;
                    //设置你的操作事项
                }
            });
            builder1.create().show();

        }
    }
    private class MyExpandableListViewAdapter extends BaseExpandableListAdapter {
        private  Context context;
        private List<LearnRecordBean.RowsBean> rows;
        private Map<LearnRecordBean.RowsBean, List<LearnRecordBean.RowsBean.ListCourseBean>> dataset;
        public MyExpandableListViewAdapter(Context context, List<LearnRecordBean.RowsBean> rows, Map<LearnRecordBean.RowsBean, List<LearnRecordBean.RowsBean.ListCourseBean>> dataset) {
            this.context = context;
            this.rows = rows;
            this.dataset = dataset;
        }
        //  获得某个父项的某个子项
        @Override
        public Object getChild(int parentPos, int childPos) {
            return dataset.get(rows.get(parentPos)).get(childPos);
        }

        //  获得父项的数量
        @Override
        public int getGroupCount() {
            return dataset.size();
        }

        //  获得某个父项的子项数目
        @Override
        public int getChildrenCount(int parentPos) {
            return dataset.get(rows.get(parentPos)).size();
        }

        //  获得某个父项
        @Override
        public Object getGroup(int parentPos) {
            return dataset.get(rows.get(parentPos));
        }

        //  获得某个父项的id
        @Override
        public long getGroupId(int parentPos) {
            return parentPos;
        }

        //  获得某个父项的某个子项的id
        @Override
        public long getChildId(int parentPos, int childPos) {
            return childPos;
        }

        //  按函数的名字来理解应该是是否具有稳定的id，这个方法目前一直都是返回false，没有去改动过
        @Override
        public boolean hasStableIds() {
            return false;
        }

        //  获得父项显示的view
        @Override
        public View getGroupView(int parentPos, boolean b, View view, ViewGroup viewGroup) {
            if (view == null) {
                LayoutInflater inflater = (LayoutInflater) UnfinishLearnRecordActivity.this
                        .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                view = inflater.inflate(R.layout.record_parent_item, null);
            }
            view.setTag(R.layout.record_parent_item, parentPos);
            view.setTag(R.layout.record_child_item, -1);
            ImageView img_parent =(ImageView) view.findViewById(R.id.img_parent);
            TextView tv_chName =(TextView) view.findViewById(R.id.tv_parent);//学时名称
            TextView tv_creationDate =(TextView) view.findViewById(R.id.tv_parent3);//开始日期
            TextView tv_timesum =(TextView) view.findViewById(R.id.tv_parent2);//学时
            TextView tv_ChLength =(TextView) view.findViewById(R.id.tv_parent6);//设定时长与实际时长
            ImageView tv_comple =(ImageView) view.findViewById(R.id.tv_parent4);//完成
            ImageView tv_complesign =(ImageView) view.findViewById(R.id.tv_parent8);//完成签名
            ImageView tv_Notthrough =(ImageView) view.findViewById(R.id.tv_parent5);//未通过
            ImageView tv_checktgrough =(ImageView) view.findViewById(R.id.tv_parent7);//抽查通过
            TextView record_parent_line =(TextView) view.findViewById(R.id.record_parent_line);
            TextView record_parent_sign =(TextView) view.findViewById(R.id.tv_parent9);//签名按钮
            RelativeLayout re_des =(RelativeLayout) view.findViewById(R.id.re_des);
            TextView tv_des =(TextView) view.findViewById(R.id.tv_des);//审核描述
            ShowGridView gv_parent =(ShowGridView) view.findViewById(R.id.gv_parent);
            LinearLayout re_nodata =(LinearLayout) view.findViewById(R.id.re_nodata);//子类无数据
            gv_parent.setClickable(false);
            gv_parent.setPressed(false);
            gv_parent.setEnabled(false);
            //      LinearLayout.LayoutParams linearParams =(LinearLayout.LayoutParams) record_parent_line.getLayoutParams(); //取控件textView当前的布局参数
            final LearnRecordBean.RowsBean rowsBean = rows.get(parentPos);

            if(rowsBean.getPjtMark()==1)
            {
                tv_chName.setText("岗前培训 · "+rowsBean.getChName());
            }else{

                tv_chName.setText(rowsBean.getChName());
            }

            long creationDate = rowsBean.getCreationDate();
            String begin="";
            try {
                //yyyy表示年MM表示月dd表示日
                //yyyy-MM-dd是日期的格式，比如2015-12-12如果你要得到2015年12月12日就换成yyyy年MM月dd日
                SimpleDateFormat sdf=new SimpleDateFormat("yyyy/MM/dd");
                //进行格式化
                begin=sdf.format(creationDate);
            } catch (Exception e) {
                e.printStackTrace();
            }
            tv_creationDate.setText("最近学习时间: "+begin);

            tv_timesum.setText(rowsBean.getChNo()+"学时");
            tv_ChLength.setText(rowsBean.getActualChLength()+"分钟/"+rowsBean.getSetChLength()+"分钟");


            if(rowsBean.getCheckMark()==2)
            {
                tv_Notthrough.setVisibility(View.VISIBLE);
                tv_Notthrough.setImageResource(R.mipmap.bj_21);
                tv_comple.setImageResource(R.mipmap.bj_11);
//                if(rowsBean.getPjtMark()==1)//判断是否是岗前培训
//                {
//                    tv_complesign.setVisibility(View.GONE);
//                    record_parent_sign.setVisibility(View.GONE);//签名按钮
//                }else {
                tv_complesign.setVisibility(View.VISIBLE);
                tv_complesign.setImageResource(R.mipmap.bj_111);//已签名
                record_parent_sign.setVisibility(View.VISIBLE);//签名按钮
                record_parent_sign.setText("查看签名");
                record_parent_sign.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {
                        if (Utils.isFastDoubleClick()) {
                            return;
                        }
                        String signPicUrl = rowsBean.getSignPicUrl();
                        Bundle bundle = new Bundle();
                        bundle.putString("signPicUrl", signPicUrl);
                        startActivity(SignCourseActivity.class, bundle);
                    }
                });

            }else if(rowsBean.getCheckMark()==1)
            {
                tv_Notthrough.setVisibility(View.VISIBLE);
                tv_Notthrough.setImageResource(R.mipmap.bj_09);
                tv_comple.setImageResource(R.mipmap.bj_11);
//                if(rowsBean.getPjtMark()==1)//判断是否是岗前培训
//                {
//                    tv_complesign.setVisibility(View.GONE);
//                    record_parent_sign.setVisibility(View.GONE);//签名按钮
//                }else {
                tv_complesign.setVisibility(View.VISIBLE);
                tv_complesign.setImageResource(R.mipmap.bj_111);//已签名
                record_parent_sign.setVisibility(View.VISIBLE);//签名按钮
                record_parent_sign.setText("查看签名");
                record_parent_sign.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {
                        if (Utils.isFastDoubleClick()) {
                            return;
                        }
                        String signPicUrl = rowsBean.getSignPicUrl();
                        Bundle bundle = new Bundle();
                        bundle.putString("signPicUrl", signPicUrl);
                        startActivity(SignCourseActivity.class, bundle);
                    }
                });

            }else if(rowsBean.getCheckMark()==0)
            {


                if(rowsBean.getFinishMark()==1)
                {
                    tv_comple.setImageResource(R.mipmap.bj_11);
//                if(rowsBean.getPjtMark()==1)//判断是否是岗前培训
//                {
//                    tv_complesign.setVisibility(View.GONE);
//                    record_parent_sign.setVisibility(View.GONE);//签名按钮
//
//                }else{
                    tv_Notthrough.setVisibility(View.VISIBLE);
                    tv_Notthrough.setImageResource(R.mipmap.bj_03);
                    tv_complesign.setVisibility(View.VISIBLE);
                    tv_complesign.setImageResource(R.mipmap.bj_112);//未签名
                    record_parent_sign.setVisibility(View.GONE);//签名按钮
//                    record_parent_sign.setText("签名");
//
//                    record_parent_sign.setOnClickListener(new View.OnClickListener() {
//                        @Override
//                        public void onClick(View view) {
//                            if (Utils.isFastDoubleClick()) {
//                                return;
//                            }
//                            int sn =rowsBean.getSn();
//                            Bundle bundle = new Bundle();
//                            bundle.putInt("sn", sn);
//
//                            bundle.putString("signPicUrl", "");
//                            startActivity(SignActivity.class, bundle);
//                        }
//                    });

                }else if(rowsBean.getFinishMark()==2)
                {
                    tv_comple.setImageResource(R.mipmap.bj_11);
//                if(rowsBean.getPjtMark()==1)//判断是否是岗前培训
//                {
//                    tv_complesign.setVisibility(View.GONE);
//                    record_parent_sign.setVisibility(View.GONE);//签名按钮
//                }else {
                    tv_Notthrough.setVisibility(View.VISIBLE);
                    tv_Notthrough.setImageResource(R.mipmap.bj_03);
                    tv_complesign.setVisibility(View.VISIBLE);
                    tv_complesign.setImageResource(R.mipmap.bj_111);//已签名
                    record_parent_sign.setVisibility(View.VISIBLE);//签名按钮
                    record_parent_sign.setText("查看签名");
                    record_parent_sign.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View view) {
                            if (Utils.isFastDoubleClick()) {
                                return;
                            }
                            String signPicUrl = rowsBean.getSignPicUrl();
                            Bundle bundle = new Bundle();
                            bundle.putString("signPicUrl", signPicUrl);
                            startActivity(SignCourseActivity.class, bundle);
                        }
                    });

                }
                else if(rowsBean.getFinishMark()==0)
                {
                    tv_comple.setImageResource(R.mipmap.bj_23);
//                if(rowsBean.getPjtMark()==1)//判断是否是岗前培训
//                {
//                    tv_complesign.setVisibility(View.GONE);
//                    record_parent_sign.setVisibility(View.GONE);//签名按钮
//                }else {
                    tv_Notthrough.setVisibility(View.GONE);
                    tv_complesign.setVisibility(View.GONE);
                    record_parent_sign.setVisibility(View.GONE);

                }


            }

//            if(rowsBean.getFinishMark()==1)
//            {
//                tv_comple.setImageResource(R.mipmap.bj_11);
////                if(rowsBean.getPjtMark()==1)//判断是否是岗前培训
////                {
////                    tv_complesign.setVisibility(View.GONE);
////                    record_parent_sign.setVisibility(View.GONE);//签名按钮
////
////                }else{
//                    tv_Notthrough.setVisibility(View.VISIBLE);
//                    tv_complesign.setVisibility(View.VISIBLE);
//                    tv_complesign.setImageResource(R.mipmap.bj_112);//未签名
//                    record_parent_sign.setVisibility(View.VISIBLE);//签名按钮
//                    record_parent_sign.setText("签名");
//                    record_parent_sign.setOnClickListener(new View.OnClickListener() {
//                        @Override
//                        public void onClick(View view) {
//                            if (Utils.isFastDoubleClick()) {
//                                return;
//                            }
//                            int sn =rowsBean.getSn();
//                            Bundle bundle = new Bundle();
//                            bundle.putInt("sn", sn);
//                            startActivity(SignActivity.class, bundle);
//                        }
//                    });
//  //              }
//
//            }else if(rowsBean.getFinishMark()==2)
//            {
//                tv_comple.setImageResource(R.mipmap.bj_11);
////                if(rowsBean.getPjtMark()==1)//判断是否是岗前培训
////                {
////                    tv_complesign.setVisibility(View.GONE);
////                    record_parent_sign.setVisibility(View.GONE);//签名按钮
////                }else {
//                    tv_Notthrough.setVisibility(View.VISIBLE);
//                    tv_complesign.setVisibility(View.VISIBLE);
//                    tv_complesign.setImageResource(R.mipmap.bj_111);//已签名
//                    record_parent_sign.setVisibility(View.VISIBLE);//签名按钮
//                    record_parent_sign.setText("查看签名");
//                    record_parent_sign.setOnClickListener(new View.OnClickListener() {
//                        @Override
//                        public void onClick(View view) {
//                            if (Utils.isFastDoubleClick()) {
//                                return;
//                            }
//                            String signPicUrl = rowsBean.getSignPicUrl();
//                            Bundle bundle = new Bundle();
//                            bundle.putString("signPicUrl", signPicUrl);
//                        }
//                    });
//              //  }
//            }
//            else if(rowsBean.getFinishMark()==0)
//            {
//                    tv_comple.setImageResource(R.mipmap.bj_23);
////                if(rowsBean.getPjtMark()==1)//判断是否是岗前培训
////                {
////                    tv_complesign.setVisibility(View.GONE);
////                    record_parent_sign.setVisibility(View.GONE);//签名按钮
////                }else {
//                    tv_Notthrough.setVisibility(View.GONE);
//                    tv_complesign.setVisibility(View.GONE);
//                    record_parent_sign.setVisibility(View.GONE);
//
//            }

            if(rowsBean.getSpotCheckMark()==1)
            {
                tv_checktgrough.setImageResource(R.mipmap.bj_07);
            }else if(rowsBean.getSpotCheckMark()==2)
            {
                tv_checktgrough.setImageResource(R.mipmap.bj_19);
            }else{
                tv_checktgrough.setVisibility(View.INVISIBLE);
            }


            if(b)//判断展开
            {
                if(rowsBean.getListCourse().size()==0)
                {
                    re_nodata.setVisibility(View.VISIBLE);
                }
                img_parent.setImageResource(R.mipmap.jianhao);
                record_parent_line.setVisibility(View.GONE);
                gv_parent.setVisibility(View.VISIBLE);
//                List<LearnRecordBean.RowsBean.PhotoListBean> photoList = rows.get(parentPos).getPhotoList();
//                MyGridViewAdapter gridViewAdapter = new MyGridViewAdapter(UnfinishLearnRecordActivity.this,photoList );
//                gv_parent.setAdapter(gridViewAdapter);
                int sn = rows.get(parentPos).getSn();
                initphotodata(sn,gv_parent);//照片展示
                if(rowsBean.getCheckMark()==2)
                {
                    re_des.setVisibility(View.VISIBLE);
                    tv_des.setText(rows.get(parentPos).getCheckDesc());

                }else if(rowsBean.getCheckMark()==1)
                {

                    re_des.setVisibility(View.GONE);

                }else if(rowsBean.getCheckMark()==0)
                {

                    re_des.setVisibility(View.GONE);
                }

            }else{
                re_nodata.setVisibility(View.GONE);
                gv_parent.setVisibility(View.GONE);
                re_des.setVisibility(View.GONE);
//                tv_comple.setVisibility(View.INVISIBLE);
//                tv_Notthrough.setVisibility(View.INVISIBLE);
//                tv_checktgrough.setVisibility(View.INVISIBLE);
                img_parent.setImageResource(R.mipmap.jiahao);
//                linearParams.height = 16;// 控件的高强制设成15
//                record_parent_line.setLayoutParams(linearParams);
                record_parent_line.setVisibility(View.VISIBLE);

            }

            return view;
        }

        private void initphotodata(int sn,final ShowGridView gv_parent) {

            OkGo.get(AppInterfaceConfig.BASE_URL + "course/userTcPhoto/find/" + sn)
                    .tag(this)
                    .execute(new StringCallback() {
                        @Override
                        public void onSuccess(String s, Call call, Response response) {
                         SpecifiedPhotoBean photoBean = JSON.parseObject(s, SpecifiedPhotoBean.class);
                        List<SpecifiedPhotoBean.RowsBean> rows = photoBean.getRows();
                        photoList.clear();
                        if(rows.size()==0)
                        {
                            return;
                        }
                         photoList.addAll(rows);
                        MyGridViewrecordAdapter gridViewAdapter = new MyGridViewrecordAdapter(UnfinishLearnRecordActivity.this,photoList );
                         gv_parent.setAdapter(gridViewAdapter);
                        }
                        @Override
                        public void onError(Call call, Response response, Exception e) {
                            super.onError(call, response, e);

                        }
                    });


        }

        //  获得子项显示的view
        @Override
        public View getChildView(int parentPos, int childPos, boolean b, View view, ViewGroup viewGroup) {
            if (view == null) {
                LayoutInflater inflater = (LayoutInflater) UnfinishLearnRecordActivity.this
                        .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                view = inflater.inflate(R.layout.record_child_item, null);
            }
            view.setTag(R.layout.record_parent_item, parentPos);
            view.setTag(R.layout.record_child_item, childPos);
            TextView tv_courseName =(TextView)view.findViewById(R.id.tv_child);
            TextView tv_creationDate =(TextView)view.findViewById(R.id.tv_child1);
            ImageView tv_muMark =(ImageView)view.findViewById(R.id.tv_child2);
     //       TextView tv_newlearning =(TextView)view.findViewById(R.id.tv_child5);//从新学习

            final  LearnRecordBean.RowsBean rowsBean = rows.get(parentPos);
            final     LearnRecordBean.RowsBean.ListCourseBean listCourseBean = dataset.get(rowsBean).get(childPos);




            tv_courseName.setText(listCourseBean.getCourseName());
            long creationDate = listCourseBean.getCreationDate();
            String learn="";
            try {
                //yyyy表示年MM表示月dd表示日
                //yyyy-MM-dd是日期的格式，比如2015-12-12如果你要得到2015年12月12日就换成yyyy年MM月dd日
                SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
                //进行格式化
                learn=sdf.format(creationDate);
            } catch (Exception e) {
                e.printStackTrace();
            }
            tv_creationDate.setText(learn);
            if(listCourseBean.getMuMark()==1)
            {
                tv_muMark.setVisibility(View.VISIBLE);
            }else{
                tv_muMark.setVisibility(View.INVISIBLE);
            }


//            if(rowsBean.getCheckMark()==0)//待审核
//            {
//                int chType = rowsBean.getChType();
//                if(chType==2)//线下学习（没有重新学习）
//                {
//                    tv_newlearning.setVisibility(View.INVISIBLE);
//                }else{
//                    tv_newlearning.setVisibility(View.VISIBLE);
//                }
//                tv_newlearning.setOnClickListener(new View.OnClickListener() {
//                    @Override
//                    public void onClick(View view) {
//                        if(rowsBean.getPjtMark()==1)//从新学习跳转岗前培训课程
//                        {
//                            showLoadingDialog("正在加载");
//                            int utchSn = rowsBean.getSn();
//                            int sn1 = listCourseBean.getSn();
//                            int tcSn = listCourseBean.getTcSn();
//                            SharedPreferences sp = getSharedPreferences("userIdandorgid",
//                                    Context.MODE_PRIVATE);
//                            int minPer = sp.getInt("minPer", 0);
//                            Bundle bundle = new Bundle();
//                            bundle.putInt("utchSn",utchSn);
//                            bundle.putInt("sn",sn1);
//                            bundle.putInt("tcSn",tcSn);
//                            bundle.putInt("minPer",minPer);
//                            startActivity(NewPrejobCourseDetailsActivity.class, bundle);
//
//                        }else{//课程超市和指定学习从新学习
//                            showLoadingDialog("正在加载");
//                            int utchSn = rowsBean.getSn();
//                            int sn2 = listCourseBean.getSn();
//                            int tcSn = listCourseBean.getTcSn();
//                            int chType = rowsBean.getChType();
//                            SharedPreferences sp = getSharedPreferences("userIdandorgid",
//                                    Context.MODE_PRIVATE);
//                            int minPer = sp.getInt("minPer", 0);
//                            if(chType==1)
//                            {
//
//                                Bundle bundle = new Bundle();
//                                bundle.putInt("utchSn",utchSn);
//                                bundle.putInt("sn",sn2);
//                                bundle.putInt("tcSn",tcSn);
//                                bundle.putInt("minPer",minPer);
//                                startActivity(NewSpecifiedAndCourseDetailsActivity.class, bundle);
//                            }else if(chType==3)//单位人员
//                            {
//                                Bundle bundle = new Bundle();
//                                bundle.putInt("sn",sn2);
//                                bundle.putInt("tcSn",tcSn);
//                                bundle.putInt("minPer",minPer);
//                                startActivity(NewSpecifiedAndCourseBusinessDetailsActivity.class, bundle);
//                            }else if(chType==4)//企业管理人员
//                            {
//                                Bundle bundle = new Bundle();
//                                bundle.putInt("sn",sn2);
//                                bundle.putInt("tcSn",tcSn);
//                                bundle.putInt("minPer",minPer);
//                                startActivity(NewSpecifiedAndCourseBusinessDetailsActivity.class, bundle);
//                            }
//                        }
//                    }
//                });
//
//
//            }
//            else{
//                tv_newlearning.setVisibility(View.INVISIBLE);
//            }



            return view;
        }

        //  子项是否可选中，如果需要设置子项的点击事件，需要返回true
        @Override
        public boolean isChildSelectable(int i, int i1) {
            return true;
        }
    }
}
